package com.jxb.demo.page;

import java.io.Serializable;

/**
 * @desc 分页基础配置
 * @author jiaxuebing
 */
public class PageInfo implements Serializable {

    private Integer pageNum = 1;//当前页数

    private Integer pageSize = 10;//每页显示条数

    private Long total = 0L;//总记录数

    private Long start;//开始查询记录索引，索引从0开始

    private Integer totalPages = 0;//总页数

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getStart() {
        return Long.valueOf((pageNum-1)*pageSize);
    }

    public void setStart(Long start) {
        this.start = start;
    }

    public Integer getTotalPages() {
        if(total <= pageSize){
            totalPages = 1;
        }else{
            Long mod = total % pageSize;
            if(mod == 0L){
                Long pages = total/pageSize;
                totalPages = pages.intValue();
            }else{
                Long pages = total/pageSize;
                totalPages = pages.intValue()+1;
            }
        }
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }
}
